package dev.guu.fx.zh.translator;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;

import java.io.IOException;

public class AppMain extends Application {
    @Override
    public void start(Stage stage) throws IOException {

        AnchorPane pane = new AnchorPane();
        Scene scene = new Scene(pane, 1000, 600);
        stage.setScene(scene);
        stage.show();
        stage.setOnCloseRequest(e -> System.exit(0));


        TextField label00 = new TextField();
        label00.setPromptText("源文件：");
        label00.setStyle("-fx-text-fill: blue; -fx-font-size: 16px;");
        label00.setPrefWidth(800);

        TextField label10 = new TextField( );
        label10.setPromptText("输出文件：");
        label10.setStyle("-fx-text-fill: blue; -fx-font-size: 16px;");
        label10.setPrefWidth(800);

        Button btn = new Button("翻译");
        btn.setOnMouseClicked(e -> {
            System.out.println("点击按钮");
        });

        scene.widthProperty().addListener((observable, oldValue, newValue) -> {
            double nv = newValue.doubleValue() - 200;
            label00.setPrefWidth(nv);
            label10.setPrefWidth(nv);

            AnchorPane.setLeftAnchor(btn, newValue.doubleValue()/2);
        });


        pane.getChildren().addAll(label00, label10,btn );
        AnchorPane.setTopAnchor(label00, 100d);
        AnchorPane.setLeftAnchor(label00, 100d);

        AnchorPane.setTopAnchor(label10, 300d);
        AnchorPane.setLeftAnchor(label10, 100d);

        AnchorPane.setTopAnchor(btn, 450d);
        AnchorPane.setLeftAnchor(btn, 500d);

//        setLabels(   );
    }
    private void setLabels(Label... labels) {
        for (Label label : labels) {
            label.setTextFill(Color.BLUE);
            label.setFont(Font.font("微软雅黑", FontWeight.BOLD, 20));
        }
    }
}
